package com.huang.deadLock;

/*
*  jsp -l 查看进程
*  jstack 进程号   查看进程问题
*
*   出现死锁  1查看日志 2查看堆栈信息
*
* */
public class Deemo {

    public static void main(String[] args) {
        String a1="a1";
        String b1="b1";

        new Thread(new mythread(a1,b1),"A").start();
        new Thread(new mythread(b1,a1),"B").start();
    }
}
class mythread implements Runnable{
    String a="a";
    String b="b";

    public mythread(String a, String b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public void run() {
            synchronized (a){
                System.out.println("当前锁的是a想要获取"+b);
                synchronized (b){
                    System.out.println("当前锁的是b想要获取"+a);
                }
            }
    }
}
